异常信息;

org.springframework.data.redis.serializer.SerializationException: Cannot deserialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is org.springframework.core.NestedIOException: Failed to deserialize object type; nested exception is java.lang.ClassNotFoundException: com.zzgele.qmkx.info.enums.InfomationTypeEnum
    at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.deserialize(JdkSerializationRedisSerializer.java:84) ~[spring-data-redis-2.0.7.RELEASE.jar!/:2.0.7.RELEASE]
    at org.springframework.data.redis.serializer.SerializationUtils.deserializeValues(SerializationUtils.java:54) ~[spring-data-redis-2.0.7.RELEASE.jar!/:2.0.7.RELEASE]
    at org.springframework.data.redis.serializer.SerializationUtils.deserialize(SerializationUtils.java:68) ~[spring-data-redis-2.0.7.RELEASE.jar!/:2.0.7.RELEASE]
    at org.springframework.data.redis.core.AbstractOperations.deserializeValues(AbstractOperations.java:268) ~[spring-data-redis-2.0.7.RELEASE.jar!/:2.0.7.RELEASE]
    at org.springframework.data.redis.core.DefaultListOperations.lambda$range$6(DefaultListOperations.java:171) ~[spring-data-redis-2.0.7.RELEASE.jar!/:2.0.7.RELEASE]
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:224) ~[spring-data-redis-2.0.7.RELEASE.jar!/:2.0.7.RELEASE]
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:184) ~[spring-data-redis-2.0.7.RELEASE.jar!/:2.0.7.RELEASE]
    at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:95) ~[spring-data-redis-2.0.7.RELEASE.jar!/:2.0.7.RELEASE]
    at org.springframework.data.redis.core.DefaultListOperations.range(DefaultListOperations.java:171) ~[spring-data-redis-2.0.7.RELEASE.jar!/:2.0.7.RELEASE]
    at com.zzgele.qmkx.info.service.impl.InfomationServiceImpl.refreshInfo(InfomationServiceImpl.java:1116) ~[classes!/:0.0.1-SNAPSHOT]
    at com.zzgele.qmkx.info.service.impl.InfomationServiceImpl.getVideoInfomationList(InfomationServiceImpl.java:881) ~[classes!/:0.0.1-SNAPSHOT]
    at com.zzgele.qmkx.info.controller.InfomationController.getVideoInfomationList(InfomationController.java:375) ~[classes!/:0.0.1-SNAPSHOT]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_172]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_172]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_172]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_172]
Caused by: org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is org.springframework.core.NestedIOException: Failed to deserialize object type; nested exception is java.lang.ClassNotFoundException: com.zzgele.qmkx.info.enums.InfomationTypeEnum
    at org.springframework.core.serializer.support.DeserializingConverter.convert(DeserializingConverter.java:78) ~[spring-core-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
    at org.springframework.core.serializer.support.DeserializingConverter.convert(DeserializingConverter.java:36) ~[spring-core-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
    at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.deserialize(JdkSerializationRedisSerializer.java:82) ~[spring-data-redis-2.0.7.RELEASE.jar!/:2.0.7.RELEASE]
    ... 84 common frames omitted
Caused by: org.springframework.core.NestedIOException: Failed to deserialize object type; nested exception is java.lang.ClassNotFoundException: com.zzgele.qmkx.info.enums.InfomationTypeEnum
    at org.springframework.core.serializer.DefaultDeserializer.deserialize(DefaultDeserializer.java:75) ~[spring-core-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
    at org.springframework.core.serializer.support.DeserializingConverter.convert(DeserializingConverter.java:73) ~[spring-core-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
    ... 86 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.zzgele.qmkx.info.enums.InfomationTypeEnum
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_172]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_172]
    at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93) ~[qmkx-service-info.jar:0.0.1-SNAPSHOT]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_172]
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:274) ~[spring-core-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
    at org.springframework.core.ConfigurableObjectInputStream.resolveClass(ConfigurableObjectInputStream.java:76) ~[spring-core-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1866) ~[na:1.8.0_172]
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1749) ~[na:1.8.0_172]
    at java.io.ObjectInputStream.readEnum(ObjectInputStream.java:1992) ~[na:1.8.0_172]
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1568) ~[na:1.8.0_172]
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2285) ~[na:1.8.0_172]
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2209) ~[na:1.8.0_172]
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2067) ~[na:1.8.0_172]
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1571) ~[na:1.8.0_172]
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:431) ~[na:1.8.0_172]
    at org.springframework.core.serializer.DefaultDeserializer.deserialize(DefaultDeserializer.java:72) ~[spring-core-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
    ... 87 common frames omitted

 

 

1.问题原因

   在缓存中存放新闻的数据,当从Redis中获取缓存的时候序列化报错。因为和另外一个服务用到了共同的枚举类,同事就把这个枚举类放到了公共的Common项目中,但是Redis中存贮着旧的数据。

   Redis存贮的数据中带着类路径,所以JDK序列化的时候找不到这个类,就抛出Caused by: java.lang.ClassNotFoundException,把缓存清除一下。问题解决。